﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AspNetCs.Common;
using AspNetCs.Bll;
using AspNetCs.Model;
using AspNetCs.Enumerations;
using AspNetCs.Enumerations.Channel_Enum;
using AspNetCs.Enumerations.memorial_enum;


public partial class Users_SelectMemorialTemplate :BasePage
{
    protected int id = 0;
    protected memorial_model MemorialModel = new memorial_model();
    protected Memorial MemorialBll = new Memorial();
    protected Memorial_Type_Model MemorialTypeModel = new Memorial_Type_Model();
    protected AspNetCs.Bll.Temple templateBLL = AspNetCs.Bll.TempleBll.CreateNew;

    protected int CurrTypeInt = 1;
    protected int EnumTypeInt = (int)Person_TypeInt_Enum.both;
    protected int IsPwdUI = 0;
    protected string PwdShow = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        CheckUserExit("Login.Aspx", "请您登录", true);
        if (Request["id"] != null)
        {
            id = StringHelper.isNumber_int(Request["id"].ToString());
        }
        if (id <= 0)
        {
            ShowMsgBack("参数传递错误！");
            Response.End();
        }

        Base_CurrPath = Base_CurrPath + " >> 会员管理中心 >> 纪念馆管理 >> 模板选择";
        CheckUserExit("Login.Aspx?ReUrl=" + configInfo.InstallDir + "Users/SelectMemorialTemplate_" + id + ".Aspx", "", true);

        MemorialModel = MemorialBll.GetModel(id);
        if (Base_GetLoginInfo.GetUserID != MemorialModel.CreateId)
        {
            ShowMsgBack("当前纪念馆不属于您创建,你暂时不能对她进行管理");
            Response.End();
        }


        CurrTypeInt = MemorialTypeModel.TypeInt;
        IsPwdUI = MemorialModel.IsEncrypt;
        if (IsPwdUI == 1)
        {
            PwdShow = EncryptString.GetDecrypt(MemorialModel.GetPwd);
        }


    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        DrePoint();
    }

    protected void DrePoint()
    {
        Users userBll = Users_Bll.CreatNew;
        int UserId = Base_GetUserInfo.UserId;
        //int needPoint = CreateNetMuPoint(NetMuTypeEnum(model.MuType));
        int TemplatePoint = StringHelper.isNumber_int(Request["hldTemplePoint"]);
        int TempId = StringHelper.isNumber_int(Request["templateId"]);
        if (TempId == MemorialModel.TempleId)
        {
            return;
            Response.Write("<script>alert('保存成功!');</script>");
        }
        if (UserId != 0)
        {
            if (TemplatePoint != 0)
            {
                userBll.DrePoint(TemplatePoint, UserId);
            }
        }
        else
        {
            CheckUserExit("Login.Aspx?ReUrl=" + configInfo.InstallDir + "Users/SelectMemorialTemplate_"+this.id+".aspx", "请您登录", true);
        }
        Response.Write("<script>alert('保存成功!');</script>");
    }
}
